package leetcode.list;

import java.util.HashSet;

/**
 * @author mazouri
 * @create 2021-08-18 21:42
 */
public class _141_hasCycle_doublePoint {
    public boolean hasCycle(ListNode head) {
        if (head==null || head.next ==null){
            return false;
        }

        ListNode fast = head;
        ListNode slow = head;

        while (fast != null && fast.next != null) {
           fast = fast.next.next;
           slow = slow.next;

           if (fast == slow){
               return true;
           }
        }

        return false;
    }
}
